package com.bw.lyc.util;

import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.View;

import androidx.appcompat.app.AppCompatActivity;

import com.blankj.utilcode.util.BarUtils;

public abstract class StatusBarColorUtils extends AppCompatActivity {

    public abstract View addStatusView();

    public void setStatusBarColor(int Color) {
        //修改状态栏当中的图片以及文字颜色
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            getWindow().getDecorView().setSystemUiVisibility(
                    View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                            | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
            //把状态栏标记为浅色，然后状态栏的字体颜色自动转换为深色
        }
        BarUtils.setStatusBarColor(this, Color);
        //添加让出状态栏高度->防止contentView布局绘制到状态栏上
        BarUtils.addMarginTopEqualStatusBarHeight(addStatusView());
    }

    protected <T extends View> T f(int id){
        return findViewById(id);
    }

    public void startPage(Bundle bundle, Class clazz) {
        Intent intent = new Intent(this,clazz);
        if (bundle!=null)
            intent.putExtras(bundle);
        startActivity(intent);
    }

    public void startPage(Class clazz){
        startPage(null,clazz);
    }
}
